<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.control.UserControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>修改密码</title>
	</head>
	<body>
		<%
			int id = (Integer) session.getAttribute("id");
			String password = (String) session.getAttribute("password");
			String oldpwd = (String) request.getParameter("old");
			String newpwd = (String) request.getParameter("new1");
			UserControl uc = new UserControl();
			if (!oldpwd.equals(password)) {
		%>
		<script>
                alert("你输入的原密码不正确，请重新输入!");
                window.location.href("update_password.jsp");
        </script>
		<%
			} else {
				if (uc.updatePassword(id, newpwd)) {
		%>
		<script>
	          alert("密码修改成功！");
	          window.location.href("../index.jsp");
	    </script>
		<%
			} else {
		%>
		<script>
             alert("修改失败！");
             window.location.href("update_password.jsp");
        </script>
		<%
			}
			}
		%>
	</body>
</html>